package jusda.caa.minio.config;

import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import java.io.IOException;

/**
 * 全局异常拦截处理
 */
@RestControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(value = CustomException.class)
    public BaseResult CustomExceptionHandle(CustomException customException) {
        return new BaseResult(customException.getErrorCode(), customException.getMessage());
    }

    @ExceptionHandler(value = IOException.class)
    public BaseResult IOExceptionHandle(IOException IOException) {
        return new BaseResult(-1, String.format("io流异常：%s",IOException.getMessage()));
    }
}